package com.zhentao.controller;

import com.zhentao.result.Result;
import com.zhentao.service.TUserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/teacher")
public class TeacherController {
    @Resource
    private TUserService tUserService;

    //老师登录只能查询自己带的班级
    @GetMapping("/getTeacherClass/{userId}")
    public Result getTeacherClass(@PathVariable("userId") Integer userId){
        Result result = tUserService.selectTeacherClass(userId);
        return result;
    }

    //查询每个班级的所有学生
    @GetMapping("/getStudentByClass/{classId}")
    public Result getStudentByClass(@PathVariable("classId") Integer classId){
        Result result = tUserService.selectStudentByClass(classId);
        return result;
    }

    //通过学生id查看最近考试情况
    @GetMapping("/getStudentExam/{studentId}")
    public Result getStudentExam(@PathVariable("studentId") Integer studentId){
        Result result = tUserService.selectStudentExam(studentId);
        return result;
    }

    //根据老师id查看老师所带班级数量,以及每个班有多少个学生。
    @GetMapping("/getTeacherClassInfo/{teacherId}")
    public Result getTeacherClassInfo(@PathVariable("teacherId") Integer teacherId){
        Result result = tUserService.selectTeacherClassInfo(teacherId);
        return result;
    }

    //通过用户编号查询所带班级一共有多少场考试，以及共有多少道题目
    @GetMapping("/getTeacherExamInfo")
    public Result getTeacherExamInfo(Integer userId){
        Result result = tUserService.selectTeacherExamInfo(userId);
        return result;
    }
}
